#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
typedef long long ll;
const ll maxn = 1e5 + 100;
ll t, n;
ll prime[maxn];
pair<ll, ll> ans[maxn];
ll cnt;
bool vis[maxn];
void init()
{
    memset(prime, 0, sizeof(prime));
    for (ll i = 2; i < maxn; i++)
    {
        if (!prime[i])
            prime[++prime[0]] = i;
        for (ll j = 1; j <= prime[0] && prime[j] * i <= maxn; j++)
        {
            prime[i * prime[j]] = 1;
            if (i % prime[j] == 0)
                break;
        }
    }
    return;
}

int main()
{
    init();
    cin >> t;
    while (t--)
    {
        cin >> n;
        cnt = 0;
        memset(vis, false, sizeof(vis));
        // ll lower_bound(prime+1,prime+n,n/2)-prime;
        for (ll i = 1; i <= prime[0] && prime[i] * 2 <= n; i++)
        {
            bool flag = false;
            ll x;
            for (ll j = 1; j * prime[i] <= n; j++)
            {
                if (vis[j * prime[i]])
                    continue;
                if (!flag)
                {
                    flag = true;
                    x = j * prime[i];
                }
                else
                {
                    ans[++cnt].first = x;
                    ans[cnt].second = j * prime[i];
                    vis[x] = true;
                    vis[j * prime[i]] = true;
                    flag = false;
                }
                // vis[j*prime[i]]=true;
            }
        }
        cout << cnt;
        for (ll i = 1; i <= cnt; i++)
        {
            cout << " " << ans[i].first << " " << ans[i].second;
        }
        cout << endl;
    }
    return 0;
}